import "babel-polyfill";
import Vue from "vue";
import App from "./App";
import { router } from "./router";
import store from "./store";

import Cookie from "js-cookie";
Vue.prototype.$cookie = Cookie;

import util from "@/plugins/util";
Vue.prototype.$auth = util.auth;

Vue.prototype.$actions = {};

import api from "@/api";
Vue.prototype.$api = api;

import vgo from "@/plugins/bus";
Vue.prototype.$vgo = vgo;

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);

import './components/'

// 全局自定义指令
import '@/plugins/directives.js'

// 全局过滤器
import '@/plugins/date.js'

Vue.config.productionTip = false;

// window.addEventListener("message", event => {
//   if ($globalconfig.URLS.WECHAT_WEB.lastIndexOf(event.origin) > -1) {
//     let data = JSON.parse(event.data);
//     if (data.type == "logout") {
//       // VM.$router.push('/')
//       window.location.href = `${
//         $globalconfig.URLS.API
//       }user/login?redirect_uri='${encodeURIComponent(location.href)}`;
//     }
//   }
// });

Vue.prototype.$WD = window

window.VM = new Vue({
  el: "#app",
  router,
  store,
  components: { App },
  template: "<App/>"
});
